<template lang="html">
  <div class="">
    <cityHeader></cityHeader>
    <citySearch></citySearch>
    <cityList :cities="cities" :hotCities="hotCities" :letter="letter"></cityList>
    <cityAlphabet :cities="cities" @change="handleLetterChange"></cityAlphabet>
  </div>
</template>

<script>
import axios from 'axios'
import cityHeader from './components/Header'
import citySearch from './components/Search'
import cityList from './components/List'
import cityAlphabet from './components/Alphabet'
export default {
  name: 'city',
  components: {
    cityHeader,
    citySearch,
    cityList,
    cityAlphabet
  },
  data () {
    return {
      hotCities: [],
      cities: {},
      letter: ''
    }
  },
  mounted () {
    this.getCityInfo()
  },
  methods: {
    getCityInfo () {
      axios.get('/api/city.json').then(res => {
        if (res.status === 200) {
          console.info(res.data)
          this.hotCities = res.data.data.hotCities
          this.cities = res.data.data.cities
        }
      })
    },
    handleLetterChange (val) {
      this.letter = val
    }
  }
}
</script>

<style lang="stylus">

</style>
